package com.cms.server.resolver.plugins;

import com.efounder.builder.base.data.EFDataSet;
import com.efounder.builder.base.data.EFRowSet;
import com.efounder.eai.data.JParamObject;
import com.efounder.form.EFFormDataModel;
import com.efounder.form.io.FormDataResolverAdapter;
import com.efounder.sql.JStatement;

public class CMSUpdateRollbackManagerApprovalPSHTForm extends FormDataResolverAdapter {

	public void saveBillData(JStatement stmt, EFFormDataModel formDataModel, JParamObject PO) throws Exception {
		int                             rowCount=0;
		EFDataSet                    billDataSet = formDataModel.getBillDataSet();
		EFRowSet                      itemRowSet;
		EFRowSet                      headRowSet;
		EFDataSet                    itemDataSet;
		String                            strSql = "";
		java.util.List<String>    dataSetKeyList = new java.util.ArrayList<String>();
		
		if(billDataSet.getRowCount() > 0) {
			headRowSet = billDataSet.getRowSet(0);
			strSql = "update PSHTXX set F_CHARDATE = '" + headRowSet.getString("F_CHDATE", "") + "' where F_DJBH = '" + headRowSet.getString("F_DJBH", "")
			       + "' and F_GUID = '" + headRowSet.getString("F_GUID", "") + "' and F_KJND = '" + headRowSet.getString("F_KJND", "") + "'";
			stmt.equals(strSql);
			
			dataSetKeyList = headRowSet.getDataSetKeyList();
			if(dataSetKeyList.size() > 0) {
				itemDataSet = headRowSet.getDataSet(dataSetKeyList.get(0));
				rowCount = itemDataSet.getRowCount();
				
				for(int i = 0; i < rowCount; i++){
			    	itemRowSet = itemDataSet.getRowSet(i);
			    	strSql = "update PSHTMX set F_CHARDATE = '" + headRowSet.getString("F_CHDATE", "") 
			    	       + "', F_FLZT = '" + itemRowSet.getString("F_FLZT", "") + "' where F_DJBH = '" + itemRowSet.getString("F_DJBH", "")
					       + "' and F_GUID = '" + itemRowSet.getString("F_GUID", "") + "' and F_KJND = '" + itemRowSet.getString("F_KJND", "") 
					       + "' and F_FLBH = '" + itemRowSet.getString("F_FLBH", "") + "'";
					stmt.equals(strSql);
			    }
			}
		}	    
	}
}
